<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true" class="nav-custom">
			<!-- <block slot="backText">返回</block> -->
			<block slot="content">重要天气</block>
		</cu-custom>

		<view class="app-box" :style="{ height: appHeight + 'px' }">
			<view v-for="(i, index) in list" :key="index" class="list-box-sv" @click="turnToPage(i)">
				<view class="f1">天气警报 {{ i.cTime | dateStr('YYYYMMDDHHmm') }}</view>
				<text class="f2 mt5">{{ i.cTime | dateStr('YYYY年MM月DD日') }}</text>
			</view>
		</view>
	</view>
</template>
<script>
	import moment from 'moment'
	import weather from '@/api/monitor/weather.js'
	export default {
		data() {
			return {
				appHeight: 0,
				list: []
			}
		},
		async mounted() {
			this.appHeight = await this.$getHeight('.nav-custom')
			this.initPage()
		},
		methods: {
			async initPage() {
				try {
					uni.showLoading({
						title: '正在加载'
					})
					let params = {
						TenantId: 142307070918780,
						ProductTypeCode: '天气警报'
					}
					const resp = await weather.weather(params)
					if (resp.success) {
						this.list = resp.data.rows.map((item) => {
							// item.cTime = moment(item.cTime).format('MM月DD日 HH:mm')
							return item
						})
						this.list = this.list.reverse()
					} else {
						// uni.showToast({
						// 	icon: 'error',
						// 	title: '获取失败'
						// })
					}
					this.$hideLoading()
				} catch (error) {}
			},
			async turnToPage(item) {
				let obj = {
					title: item.cTime,
					type: 'url',
					url: item.filePath
				}
				uni.navigateTo({ url: `/pages-subPackages/monitor/shTxt?title=${obj.title}&url=${obj.url}` })
			}
		}
	}
</script>

<style lang="less" scoped>
	.app-box {
		width: 100%;
		overflow: auto;
		padding: 0 20rpx;
		background: #fff;
	}

	.list-box-sv {
		display: flex;
		flex-direction: column;
		height: 118rpx;
		// align-items: center;
		justify-content: center;
		border-bottom: 0.5rpx solid rgba(188, 188, 188, 0.3);

		&:active {
			// background: rgba(188, 188, 188, 0.3);
		}

		.f1 {
			color: #4e4e4e;
			font-size: 28rpx;
			font-weight: 600;
		}

		.f2 {
			font-size: 20rpx;
			color: #828282;
		}
	}
</style>
